import request from '../utils/request'
// import qs from 'qs'
// 单独封装 不同接口请求

// 删除收货地址
const delContact = (params = {}) => request.post('/user/shipping-address/delete', params)
// 获取收货地址详情 /user/shipping-address/detail/v2
const fetchContactInfo = (params = {}) => request.get('/user/shipping-address/detail/v2', { params })
// 修改收货地址 /user/shipping-address/update
const updateContact = (params = {}) => request.post('/user/shipping-address/update', params)
// 新增收货地址 /user/shipping-address/add
const addContact = (params = {}) => request.post('/user/shipping-address/add', params)
// 获取收货地址列表  /user/shipping-address/list/v2
const fetchContacts = (params = {}) => request.post('/user/shipping-address/list/v2', params)
// 删除购物车购买商品 /shopping-cart/remove
const delCartItem = (params = {}) => request.post('/shopping-cart/remove', params)
// 修改商品选中状态
const setCartItemSelect = (params = {}) => request.post('/shopping-cart/select', params)
// 修改购物车商品购买数量 /shopping-cart/modifyNumber
const setCartItemNum = (params = {}) => request.post('/shopping-cart/modifyNumber', params)
// 获取购物车数据
const fetchCartItems = (params = {}) => request.get('/shopping-cart/info', { params })
// 加入购物车
const addCart = (params = {}) => request.post('/shopping-cart/add', params)
// 用户注册
const userRegister = (params = {}) => request.post('/user/username/register', params)
// 用户登录
const userLogin = (params = {}) => request.post('/user/username/login', params)
// 推荐商品
const recommendItem = (params = {}) => request.post('/shop/goods/list/v2', params)
// 商品详情
const fetchDetail = (id) => request.get('/shop/goods/detail', { params: { id } })
// 商品分类
const fetchCates = (params = {}) => request.get('/shop/goods/category/all', { params })
// 获取首页banner
const fetchHomeBanner = (params = {}) => request.get('/banner/list', { params })
export {
  fetchCates,
  fetchHomeBanner,
  recommendItem,
  fetchDetail,
  userRegister,
  userLogin,
  addCart,
  fetchCartItems,
  setCartItemNum,
  setCartItemSelect,
  delCartItem,
  fetchContacts,
  addContact,
  updateContact,
  fetchContactInfo,
  delContact
}
